<template>
  <div style="margin: 0 10px">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="进件单号" prop="queryId">
        <el-input
          v-model="queryParams.queryId"
          placeholder="请输入进件单号"
          clearable
          @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="子账号" prop="userName">
        <el-input
          style="width: 180px"
          v-model="queryParams.userName"
          placeholder="请输入子账号"
          clearable
          @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="查询项目">
        <el-select v-model="queryParams.productId" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="chargeList">
      <el-table-column label="单号" align="center" prop="id"/>
<!--      <el-table-column label="子账号ID" align="center" prop="userId"/>-->
      <el-table-column label="进件单号" align="center" prop="queryId"/>
      <el-table-column label="子账号" align="center" prop="userName"/>
<!--      <el-table-column label="子账号昵称" align="center" prop="nickName"/>-->
      <el-table-column label="查询项目" align="center" prop="productName"/>
      <el-table-column label="扣前余额" align="center" prop="beforeBalance"/>
      <el-table-column label="扣费额" align="center" prop="costNum"/>
      <el-table-column label="扣后余额" align="center" prop="afterBalance"/>
      <el-table-column label="创建时间" align="center" prop="createTime"/>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"/>
  </div>
</template>

<script>
  import {subListByParent} from "@/api/system/charge";
  import {productName} from "../../../api/system/product";

  export default {
    name: "subCharge",
    data() {
      return {
        options:[],
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 收费记录表格数据
        chargeList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,

          queryId: undefined,
          userName: undefined,
          productId: undefined
        }
      }
    },
    created() {
      this.getList();
      productName().then(response => {
        this.options = response.data;
      });
    },
    methods: {
      /** 查询收费记录列表 */
      getList() {
        this.loading = true;
        subListByParent(this.queryParams).then(response => {
          this.chargeList = response.rows;
          this.total = response.total;
          this.loading = false;
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      }
    }
  };
</script>

